package com.driver.model;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.text.SimpleDateFormat;
import org.json.JSONArray;

import com.carstop.model.CarStopDetailVO;
import com.carstop.model.CarStopVO;
import com.member.model.MemberVO;

public class CarDriverPathJsonHandler {

	
	public CarDriverPathJsonHandler() {
		super();
	}
	CarStopVO stop = null;
	public JSONArray toJSONArray(List<CarDriverPathVO> cardriverList) {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		for (CarDriverPathVO cardpathdriver : cardriverList) {
			
			
			
			String driver_path_id = cardpathdriver.getDriver_path_id();
			Integer distance = cardpathdriver.getDistance();
			Integer fee = cardpathdriver.getFee();
			Integer status = cardpathdriver.getStatus();
			Integer maxrider = cardpathdriver.getMaxrider();
			String member_id = cardpathdriver.getMember_id();
			String pool_type = cardpathdriver.getPool_type();
			String regular_id = cardpathdriver.getRegular_id();

	
			for (CarStopDetailVO stopDetail : cardpathdriver.getStopDetailList()) {				
				HashMap map = new HashMap();
				String stop_id=stopDetail.getStop_id();
				DateFormat df = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");  
				String arrival = df.format(stopDetail.getArrival());		
				
				stop =  stopDetail.getCarStop();
				String name=stop.getName();
				String town_id=stop.getTown_id();
				Double stop_latitude=stop.getStop_latitude();
				Double stop_longitude=stop.getStop_longitude();	
					
				map.put("driver_path_id", driver_path_id);
				map.put("distance", distance);
				map.put("fee", fee);
				map.put("status", status);
				map.put("maxrider", maxrider);
				map.put("member_id", member_id);
				map.put("pool_type", pool_type);
				map.put("regular_id", regular_id);		
	
			
			map.put("stop_id", stop_id);
			map.put("arrival", arrival);
			map.put("name", name);
			map.put("town_id", town_id);
			map.put("stop_latitude", stop_latitude);
			map.put("stop_longitude", stop_longitude);
			list.add(map);	
			}

				
			
		}
		JSONArray memberJson = new JSONArray(list);
		return memberJson;
	}

	
	
	
	
	
	
	
	
}
